Skip to content

Drop the wrapper and layout classes from sidebar folder toggles - #4955

Closed
akira28 wants to merge 4 commits into
mainfrom
feature/sidebar-folder-toggle
Closed

akira28 wants to merge 4 commits into
mainfrom
feature/sidebar-folder-toggle

Conversation

@akira28

@akira28 akira28 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Folder and heading rows in the sidebar no longer repeat their layout classes, and their toggle loses a wrapper element. The API sidebar is another 3–4% smaller, and it looks and behaves the same.

Affects: Site UI, API reference

Stack: 2 of 4, on top of #4953, under #4956.

Prompt summary: Stack the third sidebar markup step on top of #4953: a lighter folder toggle. The three PRs come from the sidebar analysis for elastic/docs-eng-team#1183, which is about bringing API pages under Googlebot's 2 MB HTML limit.

Why

Folder rows take about 500 bytes each, and the Kibana API sidebar has 72 of them on every page. Each title row repeated peer grid grid-cols-[1fr_auto] w-full. Each toggle repeated group/label flex mr-2 items-start on its label and wrapped its chevron in a div.nav-toggle-btn.

What

The title row keeps only peer

pages-nav.ts and the CSS that opens a subtree both find the row through peer, so it stays. A rule in Tailwind's utilities layer, at no specificity, applies the grid the classes set.

The label is the button

The chevron now sits directly in the label. The label fills the row height, as it did with the old classes, so on a title that wraps to two lines a click below the chevron still toggles the folder. The chevron takes the padding, rounding and hover background the .nav-toggle-btn wrapper had, so the button box stays 22×22 at the top of the row.

The open chevron follows the label's checkbox

The chevron's open rotation keyed on the group/label class. It now keys on .nav-folder > .peer > label:has(:checked).

Nothing that the expand and collapse logic reads changes. That logic is pages-nav.ts and NavigationCurrentMarker, and it reads the checkbox, .peer, li.nav-folder and .nav-subtree-clip. Island rows, which link out with a double chevron and have no checkbox, keep their markup.

Results

An isolated build of docs/:

main #4953 This PR
Kibana sidebar (operation-osquerydeletepacks) 279 KB 189.6 KB 181.8 KB
Elasticsearch sidebar (operation-reindex) 217 KB 155.6 KB 150.4 KB
All API HTML (7,243 pages) 2.56 GB 2.074 GB 2.032 GB
API pages over 2 MB 71 68 68

This is less than the analysis estimated (18 KB per Kibana sidebar). That estimate replaced the whole toggle with one checkbox, which would change how it is clicked and styled.

Compared with #4953's build:

  • Sidebar screenshots: pixel-identical on the Kibana and Elasticsearch pages above and on /syntax/tabs. This covers desktop and tablet size, with folders as loaded and with every folder open.
  • Hovered toggle: pixel-identical. With the label's hover rule removed, the same comparison finds 482 differing pixels, so it does catch a missing hover style.
  • Clicking a toggle: behaves the same on both builds. The checkbox checks, the subtree shows, and the chevron turns from -90° to 0°.

Out of scope: the NAVIGATION_PREVIEW styles in pages-nav-figma.css. They key on .peer, .nav-chevron and the checkbox, which this PR keeps, but I did not screenshot that flag.

Verify

dotnet test --project tests/Navigation.Tests
# LegacyHeadingRow_RendersTitleWithoutAnEmptyLink, LegacyGroupRow_RendersALabelOverItsItemsWithNoToggle (snapshots of the lighter folder row)
mise run site:test

Check on the preview

  • Kibana: Delete packs: the current folder is open with its chevron pointing down. Click a closed folder's chevron and the folder opens. Hover a chevron and it gets a grey background.
  • Upgrade: a Markdown page's sidebar folders open, close and look the same as on production.

🤖 Generated with Claude Code

@akira28
akira28 requested a review from a team as a code owner November 19, 2026 11:54
@akira28
akira28 requested a review from Mpdreamz November 19, 2026 11:54
@akira28
akira28 added this pull request to stack #4954 November 19, 2026 11:55
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4955/

@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 33a7215 to dd48757 Compare November 19, 2026 14:25
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from dd48757 to 539d8a5 Compare November 19, 2026 16:22
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 539d8a5 to dd48757 Compare November 19, 2026 16:27
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from dd48757 to 17d827c Compare November 20, 2026 08:56
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 17d827c to 09dfcc0 Compare November 23, 2026 10:51
}

/* An open folder points its chevron down; the label no longer carries the group/label class this used. */
.nav-folder > .peer > label:has(:checked) .nav-chevron {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

Add a browser regression check that clicks a legacy folder toggle and verifies subtree visibility and chevron rotation on both open and close. The updated HTML snapshots would still pass if the new checked-state selector stopped matching and the chevron stayed sideways.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this one. I checked open and close in a browser against the previous markup (checkbox state, subtree visibility and chevron rotation all match), and the sidebar screenshots, with folders open, match pixel for pixel. A dedicated browser test for the toggle is more than this markup change needs.

@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch 2 times, most recently from d46233d to e49ae66 Compare November 23, 2026 13:28
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from e49ae66 to a507da9 Compare November 23, 2026 17:30
}

:where(.nav-folder > .peer > label) {
@apply mr-2 flex items-start;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

Add a browser regression test that clicks below the chevron on a wrapped folder row and checks that the subtree opens and closes. The HTML snapshots cannot detect a return to a chevron-height hit area, and a test that clicks the chevron itself would pass either way.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this one. I checked it in a browser when making the change: on a wrapped folder title the label measures 22×34 as on main, and a click 3px above the bottom of the row toggles the folder. A browser test for one CSS rule is more than this markup change needs.

@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch 3 times, most recently from cff0079 to a369c79 Compare November 30, 2026 11:37
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from a369c79 to 6bc3c8b Compare November 30, 2026 12:01
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 6bc3c8b to 284d00f Compare November 30, 2026 12:15
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 284d00f to 7939c2f Compare November 30, 2026 12:22
Base automatically changed from feature/sidebar-method-badge to main November 30, 2026 12:48
akira28 and others added 4 commits November 30, 2026 13:48
Each folder and heading row in the legacy sidebar repeated
`peer grid grid-cols-[1fr_auto] w-full` on its title row, and
`group/label flex mr-2 items-start` plus a `nav-toggle-btn` div around
the chevron in its toggle. The row keeps `peer`, the label becomes the
button, and `styles.css` sets the grid, the label's place, its button
look and the open chevron's rotation. Island rows keep their markup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With self-start, a wrapped folder title left the area below the chevron
unclickable. The label fills the row as it did with the old wrapper, and
the chevron carries the padded hover box the inner div used to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@akira28
akira28 force-pushed the feature/sidebar-folder-toggle branch from 7939c2f to 92e139e Compare November 30, 2026 12:48
@akira28

akira28 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Closing: it trims the old sidebar's folder rows by 3–4% but moves no page under 2 MB, and that sidebar is being replaced. The larger sidebar savings merged in #4952 and #4953.

@akira28 akira28 closed this Nov 30, 2026
@akira28
akira28 deleted the feature/sidebar-folder-toggle branch November 30, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant